<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增取货码批次')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-batch-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">机器ID：</label>
                <div class="col-sm-8">
                    <!--input name="machineId" class="form-control" type="text"-->
                    <select name="machineId" class="form-control m-b" th:with="type=${machines}" onchange="machineChange()">
                        <option th:each="dict : ${type}" th:text="${dict.machineId}+'|'+${dict.machineName}" th:value="${dict.machineId}" th:machineName="${dict.machineName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">机器名称：</label>
                <div class="col-sm-8">
                    <input name="machineName" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品ID：</label>
                <div class="col-sm-8">
                    <!--input name="productId" class="form-control" type="text"-->
                    <select name="productId" class="form-control m-b" th:with="type=${products}" onchange="productChange()">
                        <option th:each="dict : ${type}" th:text="${dict.productId}+'|'+${dict.productName}" th:value="${dict.productId}" 
                        th:productName="${dict.productName}" th:productPrice="${dict.productPrice}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品名称：</label>
                <div class="col-sm-8">
                    <input name="productName" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品价格：</label>
                <div class="col-sm-8">
                    <input name="productPrice" class="form-control" type="text" readonly="readonly">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">有效起始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="effectiveStartDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">有效截止日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="effectiveEndDate" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">取货码数量：</label>
                <div class="col-sm-8">
                    <input name="pickCodeQuantity" class="form-control" type="text">
                </div>
            </div>
            <input type="hidden" name="status" value="1"/>
            <!-- div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control m-b" th:with="type=${@dict.getType('batch_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "business/batch"
        $("#form-batch-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-batch-add').serialize());
            }
        }

        $("input[name='effectiveStartDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='effectiveEndDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        function machineChange(){
        	$("[name='machineName']").val($("[name='machineId']").find("option:selected").attr("machineName"));
        }
        function productChange(){
        	$("[name='productName']").val($("[name='productId']").find("option:selected").attr("productName"));
        	$("[name='productPrice']").val($("[name='productId']").find("option:selected").attr("productPrice"));
        }
        machineChange();
        productChange();
    </script>
</body>
</html>